<template>
  <div class='search'>
    <f-drawer ref='orderDrawer' :title='title' width='87%' @submit='handleSubmit' @visibleChange='visibleChange'>
      <a-tabs @tabClick='tabClick' :defaultActiveKey='compName' v-model='compName' style='margin-top: -25px' :animated='false'>
        <a-tab-pane tab='基础信息' key='drugForm'>
          <drugs-form ref='drugForm'></drugs-form>
        </a-tab-pane>
        <a-tab-pane tab='关联商品' key='drugSetting'>
          <drugs-setting ref='drugSetting'></drugs-setting>
        </a-tab-pane>
        <a-tab-pane tab='部门结算政策' key='policyListDept'>
          <policy-list-dept ref='policyListDept'></policy-list-dept>
        </a-tab-pane>
        <a-tab-pane tab='职务结算政策' key='policyListPosition'>
          <policy-list-position ref='policyListPosition'></policy-list-position>
        </a-tab-pane>
        <a-tab-pane tab='业务员结算政策' key='policyListSaleMan'>
          <policy-list-sale-man ref='policyListSaleMan'></policy-list-sale-man>
        </a-tab-pane>
        <a-tab-pane tab='招募人结算政策' key='policyListSaleMan2'>
          <policy-list-sale-man2 ref='policyListSaleMan2'></policy-list-sale-man2>
        </a-tab-pane>
        <!--        <a-tab-pane tab='市场结算政策' key='policyListCustom'>
                  <policy-list-custom ref='policyListCustom'></policy-list-custom>
                </a-tab-pane>-->
        <a-tab-pane tab='提成(分红)政策' key='policyListBonus'>
          <policy-list-bonus ref='policyListBonus'></policy-list-bonus>
        </a-tab-pane>
      </a-tabs>
    </f-drawer>
  </div>
</template>
<script>
import PolicyListCustom from "./custom/policy_list_custom"
import PolicyListDept from "./dept/policy_list_dept"
import PolicyListSaleMan from "./saleman/policy_list_saleman"
import PolicyListSaleMan2 from "./zmsaleman/policy_list_saleman2"
import PolicyListBonus from "./bonus/policy_list_bonus"
import PolicyListPosition from "./position/policy_list_position"
import DrugsForm from "./drugs_form"
import DrugsSetting from "@/views/module/haiying/policy/settle/components/drugs/drugs_setting"

export default {
  name: "PolicyListDrawer",
  props: {},
  data() {
    return {
      refs: this.$refs,
      drawerVisible: false,
      isEdit: false,
      compName: "drugForm",
      formData: {}
    }
  },
  methods: {
    showDrawer(data) {
      this.isEdit = false
      if (data && data.policyDrugId) {
        this.isEdit = true
        this.formData = data
      } else {
        this.formData = {}
      }
      this.refs["orderDrawer"].show()
      this.tabClick("drugForm")
    },
    visibleChange(drawerVisible) {
      this.drawerVisible = drawerVisible
    },
    tabClick(compName) {
      this.compName = compName
      this.$nextTick(() => {
        this.refs[compName].setData(this.formData)
      })
    },
    handleSubmit(callback) {
      if (this.compName == "drugForm") {
        this.refs["drugForm"].handleSubmit(() => {
          this.$emit("success")
        })
      }
      if (this.compName == "drugSetting") {
        this.refs["drugSetting"].handleSubmit(() => {
          this.$emit("success")
        })
      }
    }
  },
  computed: {
    title: function() {
      return "设置结算政策(" + this.formData.drugsName + this.formData.drugsSpec + ")"
    }
  },
  created() {
  },
  components: { DrugsSetting, DrugsForm,PolicyListSaleMan2, PolicyListBonus, PolicyListSaleMan, PolicyListDept, PolicyListCustom, PolicyListPosition }
}
</script>

<style scoped lang='less' rel='stylesheet/less'>

</style>
